package com.example.stujava.module.xiangxue.reflect.gson_type

import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type

open class KcTypeReference<T> {

    lateinit var type: Type

    val t: T? = null

    constructor() {
        //获取泛型类型
        val genericSuper = javaClass.genericSuperclass as ParameterizedType
        //泛型可有多个，获取泛型数组
        val actualTypeArguments = genericSuper.actualTypeArguments
        type = actualTypeArguments[0]
    }

//    @JvmName("getType1")
//    fun getType() = type

    fun getType2(): Type {
        return type
    }
}